package bit;

public class leetcode137只出现一次的数字2 {
    public int singleNumber(int[] nums) {
        int length = nums.length;
        int result = 0;
        for (int i = 0; i < 32; i++) {
            int ans = 0;
            for (int j = 0; j < length; j++) {
                ans += (nums[j] >> i) & 1;
            }
            if (ans % 3 == 1){
                result |= 1 << i;
            }
        }
        return result;
    }
}
